<template>
	<view class="page" v-if="goodsInfo && storeInfo">
		<scroll-view :scroll-y="true" scroll-with-animation="true" :scroll-top="scrollTop">
			<view class="wrapper" :style="'padding-bottom:' + (goodsInfo.subsidiary_piece && goodsInfo.subsidiary_piece.length > 0 ? 120 : 80) + 'px;'">
				<!-- 商品图片轮播 -->
				<view class="swiper-box" v-if="!goodsInfo.pic_empty">
					<swiper
						v-if="goodsInfo.pic_arr && goodsInfo.pic_arr.length > 1"
						class="swiper"
						:style="'height:' + imageHeight + 'px'"
						indicator-color="rgba(255,255,255,0.7)"
						:indicator-dots="goodsInfo.pic_arr.length > 1"
					>
						<swiper-item v-for="(item, index) in goodsInfo.pic_arr" :key="index">
							<image :src="item.url" class="slide-image" @tap="previewImg($event)" :data-index="index"></image>
						</swiper-item>
					</swiper>

					<view v-if="goodsInfo.pic_arr.length == 1" v-for="(item, index) in goodsInfo.pic_arr" :key="index" :style="'height:' + imageHeight + 'px'">
						<image :src="item.url" class="slide-image" @tap="previewImg($event)" :data-index="index"></image>
					</view>
				</view>

				<view class="goods-info">
					<view class="desc-box">
						<view class="left">
							<view class="name">{{ goodsInfo.name }}</view>
							<view class="m-describe">{{ goodsInfo.describe }}</view>
							<goodsTip :goods="goods"></goodsTip>
						</view>
						<view class="share-btn" :style="'color:' + mobile_head_color" @click.stop="clickShow($event)" data-name="showShare">
							<text class="iconfont icon-fenxiang" :style="'border-color:' + mobile_head_color"></text>
							<view><lang keywords="分享"></lang></view>
						</view>
					</view>
					<view class="price-box">
						<view>
							<view class="price mr0 block-in">
								{{ currency + goods.product_price }}
							</view>
							<text class="price m0" style="font-size:12px;">{{ ' / ' + goods.unit }}</text>
							<view class="block-in old-price" v-if="goods.is_seckill_price && goods.o_price > goods.product_price">
								{{ currency + goods.o_price }}
							</view>
						</view>
						<view v-if="goods.is_subsidiary_goods != 1">
							<count :goods="goods" :isGoodsPage="true" :refreshCount="refreshCount" @getGoods="getGoods" ></count>
						</view>
					</view>
					
					<!-- 称重商品 -->
					<view class='weight-box' v-if="goodsInfo.sell_type == 2">
						<view class="desc-box">
							<lang class="tag" keywords="结算" chineseTxt="结算"></lang>
							<text>{{currency + goodsInfo.unit_price}}/</text>
							<lang keywords="斤" chineseTxt="斤"></lang>
							<text class="iconfont icon-gantanhao" @tap='clickShow($event)' data-name='showDesc'></text>
						</view>
						<view class="desc-box">
							<lang class="tag" keywords="规格" chineseTxt="规格"></lang>
							<lang keywords="约" chineseTxt="约"></lang>
							<text>{{goodsInfo.weight + (goodsInfo.weight_unit == 1 ? 'g' : 'kg')}}</text>
						</view>
					</view>
				</view>
				
				<view class="goods-info remarks border-t" v-if="goodsInfo.spec_list.length > 0">
					<view class="select-flavor" v-for="(spec, specIndex) in goodsInfo.spec_list" :key="specIndex">
						<view class="title">{{ spec.name }}</view>
						<view class="flavor-box">
							<view
								:class="'item ' + (goods.spec_list[specIndex].id_ === item.id_ ? 'active' : '')"
								:style="'color:' + (goods.spec_list[specIndex].id_ === item.id_ ? mobile_head_color : '')"
								v-for="(item, index) in spec.list"
								:key="index"
								@tap="selectSpec($event)"
								:data-index1="specIndex"
								:data-index2="index"
							>
								{{ item.name }}
							</view>
						</view>
					</view>
				</view>
				
				<!-- 组合套餐 -->
				<view class="pack-meal" v-if="goodsInfo.combination_list && goodsInfo.combination_list.length > 0">
					<view class="pack-meal-wrapper">
						<view class="list">
							<view :class="'item ' + (item.goods.length > 2 ? 'three' : '')" v-if="itemIndex < 2" v-for="(item, itemIndex) in goodsInfo.combination_list" :key="item.com_id" @click="clickShow($event)" data-name="showPackMeal">
								<view class="title">
									<text>{{item.name}}</text>
									<text class="dot">·</text>
									<lang keywords="X1件商品" :X1="item.goods.length"></lang>
									<block v-if="item.sell_count > 0">
										<text class="dot">·</text>
										<lang keywords="X1人这样搭配" :X1="item.sell_count"></lang>
									</block>
								</view>
								<view class="goods-list">
									<view class="goods">
										<block v-for="(goods, goodsIndex) in item.goods" :key="goods.id">
											<view class="goods-item">
												<view class="img-box"><image class="img" :src="goods.image" mode=""></image></view>
												<view>
													<lang v-if="goodsIndex == 0" keywords="当前商品"></lang>
													<text v-else class="goods-name">{{goods.name}}</text>
												</view>
											</view>
											<text class="icon">+</text>
										</block>
									</view>
									<view class="price">
										<view class="red" v-if="item.discount_price > 0"><lang keywords="搭配可省"></lang>{{currency + item.discount_price}}</view>
										<view><lang keywords="实付"></lang><text class="red ml5">{{currency}}</text><text class="red now-price">{{item.price}}</text></view>
										<view class="btn" :style="'background:' + mobile_head_color" @click.stop="addPackGoods(item.com_id)"><lang keywords="立即购买"></lang></view>
									</view>
								</view>
								<view class="price" >
									<block v-if="item.discount_price > 0">
										<lang class="red" keywords="搭配可省"></lang>
										<text class="red">{{currency + item.discount_price}}</text>
									</block>
									<lang class="ml10 txt" keywords="实付"></lang>
									<text class="red">{{currency}}</text>
									<text class="red now-price">{{item.price}}</text>
									<view class="block-in" @click.stop="addPackGoods(item.com_id)">
										<lang class="btn ml10" :style="'background:' + mobile_head_color" keywords="立即购买"></lang>
									</view>
								</view>
							</view>
							<view class="see-more" v-if="goodsInfo.combination_list.length > 2" @click="clickShow($event)" data-name="showPackMeal">
								<image class="img" :src="goodsInfo.image" mode="aspectFill"></image>
								<lang keywords="包含当前商品的X1个套餐" :X1="goodsInfo.combination_list.length"></lang>
								<text class="iconfont icon-jiantou"></text>
							</view>
						</view>
					</view>
				</view>

				<view class="linked-goods" v-for="(list, listIndex) in goodsInfo.subsidiary_piece" :key="listIndex">
					<view class="sub-goods type-name" :id="'sub-goods-' + list.id_sp">
						<view>
							{{ list.name }}
							<lang class="limit" keywords="（请选择X1份）" :X1="list.mininum" v-if="list.maxnum > 0 && list.mininum > 0 && list.maxnum == list.mininum"></lang>
							<lang
								class="limit"
								keywords="（最少选择X1份，最多选择X2份）"
								:X1="list.mininum"
								:X2="list.maxnum"
								v-else-if="list.maxnum > 0 && list.mininum > 0"
							></lang>
							<lang class="limit" keywords="（最少选择X1份）" :X1="list.mininum" v-else-if="list.maxnum == 0 && list.mininum > 0"></lang>
							<lang class="limit" keywords="（最多选择X1份）" :X1="list.maxnum" v-else-if="list.maxnum > 0 && list.mininum == 0"></lang>
						</view>
						<block v-if="list.selectNum > 0"><lang class="limit" keywords="已选X1份" :X1="list.selectNum" :needUpdate="true"></lang></block>
					</view>
					<view class="sub-goods item border-b" :id="'sub-goods-' + item.goods_id" v-for="(item, index) in list.goods" :key="index">
						<view class="item-info">
							<view class="goods-name">
								{{ item.name }}
								<view class="price" v-if="item.spec_value == ''">
									(
									{{ currency + item.price_sug }} /
									<lang keywords="份"></lang>
									)
								</view>
								<block v-else><lang class="price" keywords="(多规格)"></lang></block>
							</view>
							<view class="count-box">
								<text
									class="iconfont icon-jian"
									:style="'color:' + mobile_head_color"
									v-if="item.selectNum > 0"
									@click.stop="subsidiarySub($event)"
									:data-index="index"
									:data-listindex="listIndex"
								></text>
								<text class="num" v-if="item.selectNum > 0">{{ item.selectNum }}</text>
								<text
									:class="'iconfont icon-jia ' + (item.stock_num === 0 ? 'active' : '')"
									:style="'color:' + (item.stock_num === 0 ? '' : mobile_head_color)"
									@click.stop="subsidiaryAdd($event)"
									:data-index="index"
									:data-listindex="listIndex"
								></text>
							</view>
						</view>

						<view class="item-desc" v-if="subsidiaryGoods[item.goods_id]">{{ subsidiaryGoods[item.goods_id].desc_text }}</view>
					</view>
				</view>

				<view class="m2 goods-info remarks" v-if="!(goodsInfo.des === '' && goodsInfo.describe == '')">
					<view class="m-price-explain">
						<view class="m-price-title">
							<text>价格说明</text>
							<image :src="explainIcon" @tap="toggleShowExplainImg"></image>
						</view>
						<view class="m-price-img-wrap" v-if="showExplainImg">
							<image class="m-price-img" :src="expalinImg"></image>
						</view>
					</view>
					
					<view class="m-product-msg" v-if="mtype.length>1">
						<text class="m-product-title">产品信息</text>
						<view class="m-product-item-wrap">
							<view class="m-product-item" v-for="(item,index) in mtype" :key="index">
								{{item}}
							</view>
						</view>
					</view>
					
					<!-- <view class="name"><lang keywords="商品描述"></lang></view>
					<view class="desc-text">{{ goodsInfo.describe }}</view> -->
				</view>

				<view class="m2 goods-info" style="padding-top:10px;">
					<!-- <view class="m-sale-info-img"></view> -->
					<rich-text class="desc-text" :nodes="goodsInfo.des"></rich-text>
				</view>

				<navigator v-if="showHomeIcon && !isNewHeader" open-type="redirect" :url="'/pages/shop_new/shopDetail/shopDetail?store_id=' + store_id">
					<text class="iconfont icon-shouye1"></text>
				</navigator>
			</view>
		</scroll-view>

		<!-- 底部购物车 -->
		<shopcart :refreshCart="refreshCart" @getGoods="getGoods"></shopcart>

		<!-- 有附属菜的商品加入购物车按钮 -->
		<view :style="'background:' + mobile_head_color + ';'" class="add-to-cart" v-if="goodsInfo.subsidiary_piece && goodsInfo.subsidiary_piece.length > 0">
			<view style="padding: 5px 0;">
				<text class="iconfont icon-jia2" style="font-weight:bold;padding-left: 10px;"></text>
				<lang keywords="加入购物车"></lang>
			</view>
			<view>
				{{ currency + totalMoney }}
			</view>
			<view class="count-mask" @click.stop="addToCart"></view>
		</view>

		<!-- 分享按钮 -->
		<view :class="'shareBtnsContent ' + (showShare ? 'active' : '')">
			<view class="pub_list">
				<button class="pub_list_bd button_share" open-type="share">
					<text class="iconfont icon-weixin2"></text>
					<view class="txt"><lang keywords="分享给好友"></lang></view>
				</button>
				<button class="pub_list_bd button_share" @click.stop="clickShow($event)" data-name="showPoster">
					<text class="iconfont icon-pengyouquan"></text>
					<view class="txt"><lang keywords="生成海报"></lang></view>
				</button>
				<text class="iconfont icon-cha" @tap="closeMask($event)" data-name="showShare"></text>
			</view>
		</view>
		<view class="mask_bg" v-if="showShare" @tap="closeMask($event)" data-name="showShare"></view>

		<!-- 分享海报画布  -->
		<view :class="'shareBtnsContent canvas-box ' + (showPoster ? 'active' : '')" :style="'max-height:' + max_height + 'px;overflow:hidden;' + (!showPoster ? 'display:none;' : '')">
			<view class="goods">
				<image :style="'height:' + imageHeight * 0.8 + 'px;'" class="img" :src="goodsInfo.image"></image>
				<view style="padding:0 10px 10px;">
					<view class="goods-name">{{ goodsInfo.name }}</view>
					<view class="store-name">{{ storeInfo.name }}</view>
					<view class="star">
						<wux-rater :auto="false" slot="footer" :value="storeInfo.star" :font-size="14" disabled></wux-rater>
						<text>{{ storeInfo.star }}</text>
					</view>
					<view class="price-desc">
						<view>
							<view class="price-mark price block-in">{{currency}}</view>
							<text class="price-num price num">{{ goods.product_price }}</text>
							<view class="o-price block-in" v-if="goods.o_price > goods.product_price">
								{{ currency + goods.o_price }}
							</view>
						</view>
						<view class="desc"><lang keywords="长按小程序码去购买"></lang></view>
					</view>
					<image class="qcode" :src="goodsInfo.wxapp_qrcode"></image>
				</view>
			</view>
			<text class="iconfont icon-cha" @tap="closeMask($event)" data-name="showPoster"></text>
			<view class="btn-box">
				<block v-if="canSave">
					<button class="save-img" @tap="savePoster">
						<lang keywords="保存图片"></lang>
					</button>
				</block>
				<block v-else>
					<button class="save-img openSetting" @opensetting="handleSetting" open-type="openSetting">
						<lang keywords="保存图片"></lang>
					</button>
				</block>
			</view>
		</view>
		<view class="mask_bg" v-if="showPoster" @tap="closeMask($event)" data-name="showPoster"></view>

		<view style="width:0;height:0;overflow:hidden;position:fixed;left:10000px;"><canvas canvas-id="pubShare" :style="'width:' + width + 'px;height:' + height + 'px'"></canvas></view>

		<!-- 称重商品结算说明 -->
		<view :class="'shareBtnsContent ' + (showDesc ? 'active' : '')">
			<view class="weight-desc">
				<view class="title"><lang keywords="结算说明"></lang></view>
				<view class="desc">
					<lang	keywords="该商品为计重类商品，如果您下单后商品实际重量小于购买重量，差价部分在订单完成后会直接退回到您平台余额账户中；如果您下单商品实际重量大于购买重量，则由商家补贴差额，您不需要再次支付。"></lang>
				</view>
				<button class="btn" :style="'background:' + mobile_head_color" @tap="closeMask($event)" data-name="showDesc"><lang keywords="知道了"></lang></button>
			</view>
		</view>
		<view class="mask_bg" v-if="showDesc" @tap="closeMask($event)" data-name="showDesc"></view>
		
		<!-- 附属菜规格商品弹窗 -->
		<view class="mask" v-if="showSpecMask"></view>
		<view :class="'spec-content-wrapper ' + (showSpecMask ? 'active' : '')" @tap="closeMask($event)" data-name="showSpecMask">
			<view class="spec-content " v-if="!showSpecNumMask" @click.stop="noclose">
				<view class="header">
					<view class="goods-info">
						<view class="name">{{ specGoodsInfo.name }}</view>
						<view class="price-box">
							<view style>
								<view class="price block-in" style="margin-right:0;">
									{{currency}}{{ specGoodsInfo.list && specGoodsInfo.list[specGoods.specId].price ? specGoodsInfo.list[specGoods.specId].price : specGoodsInfo.price }}
								</view>
								<text class="price" style="font-size:12px;">{{ ' / ' + specGoodsInfo.unit }}</text>
							</view>
							<view class="select-btn" @click.stop="addSubsidiary" :style="'background:' + mobile_head_color">
								<text class="iconfont icon-jia2"></text>
								<lang keywords="选好了"></lang>
							</view>
						</view>
					</view>
					<text class="iconfont icon-cha" @tap="closeMask($event)" data-name="showSpecMask"></text>
				</view>

				<view class="spec-box" :style="'max-height:' + specHeight + 'px;'">
					<view class="rel remarks border-t" v-if="specGoodsInfo.spec_list && specGoodsInfo.spec_list.length > 0">
						<view class="select-flavor" v-for="(spec, specIndex) in specGoodsInfo.spec_list" :key="spec.id">
							<view class="title">{{ spec.name }}</view>
							<view class="flavor-box">
								<view
									:class="'item ' + (specGoods.spec_list[specIndex].id_ == item.id_ ? 'active' : '')"
									:style="'color:' + (specGoods.spec_list[specIndex].id_ === item.id_ ? mobile_head_color : '')"
									v-for="(item, index) in spec.list"
									:key="item.id_"
									@tap="selectSpec($event)"
									:data-index1="specIndex"
									:data-index2="index"
									data-tag="subsidiary"
								>
									{{ item.name }}
								</view>
							</view>
						</view>
					</view>

					<view class="rel remarks border-t" v-if="specGoodsInfo.properties_list && specGoodsInfo.properties_list.length > 0">
						<view class="name"><lang keywords="我要备注"></lang></view>
						<view class="select-flavor" v-for="(prop, propIndex) in specGoodsInfo.properties_list" :key="prop.id_">
							<view class="title">{{ prop.name }}</view>
							<view class="flavor-box">
								<view
									:class="'item ' + (item[1] == 0 ? 'active' : '')"
									:style="'color:' + (item[1] == 0 ? mobile_head_color : '')"
									v-for="(item, index) in prop.val_status"
									:key="index"
									@tap="selectProp($event)"
									:data-index1="propIndex"
									:data-index2="index"
									data-tag="subsidiary"
								>
									{{ item[0] }}
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>

			<view class="spec-content type-list" v-if="showSpecNumMask" @click.stop="noclose">
				<view class="line-wrapper">
					<view><lang keywords="已选规格商品"></lang></view>
				</view>
				<view class="select-goods" :style="'max-height:' + specHeight + 'px;'">
					<view class="goods-items border-t" v-for="(item, index) in subsidiaryGoods[specGoods.product_id].list" :key="index">
						<view class="name">{{ item.goods_text }}</view>
						<view>
							{{ currency + item.product_price }}
						</view>
						<view class="count-box">
							<text class="iconfont icon-jian" :style="'color:' + mobile_head_color" @click.stop="subSpec($event)" :data-index="index"></text>
							<text class="num">{{ item.selectNum }}</text>
							<text class="iconfont icon-jia" :style="'color:' + mobile_head_color" @click.stop="addSpec($event)" :data-index="index"></text>
						</view>
					</view>
				</view>
				<view class="cart">
					<view>
						<lang keywords="小计："></lang>
						{{ currency + subsidiaryGoods[specGoods.product_id].money }}
					</view>
					<view class="btn" :style="'backgroundColor:' + mobile_head_color" @click.stop="selectOther"><lang keywords="选择其它"></lang></view>
				</view>
			</view>
		</view>
		
		<!-- 组合套餐商品弹窗 -->
		<view class="mask_bg" v-if="showPackMeal" @tap="closeMask($event)" data-name="showPackMeal"></view>
		<view :class="'shareBtnsContent pack-meal-mask ' + (showPackMeal ? 'active' : '')" @tap="closeMask($event)" data-name="showPackMeal">
			<view class="shop-info">
				<view class="img-box"><image class="img" :src="storeInfo.image" mode=""></image></view>
				<view>
					<view class="shop-name">{{storeInfo.name}}</view>
					<view>
						<text class="iconfont icon-star score"></text>
						<text class="score">{{storeInfo.star}}</text>
						<lang class="delivery-time" keywords="配送约X1" :X1="storeInfo.delivery_time + storeInfo.delivery_time_type"></lang>
					</view>
				</view>
				<text class="iconfont icon-chahao"></text>
			</view>
			<view class="list">
				<view class="pack-goods" v-for="(item, itemIndex) in goodsInfo.combination_list" :key="item.com_id">
					<view class="goods-list">
						<view class="item" v-for="(goods, goodsIndex) in item.goods">
							<view class="img-box">
								<image class="img" :src="goods.image" mode=""></image>
								<lang v-if="item.sell_count > 0 && goodsIndex == 0" class="sell-count" keywords="X1人这样搭配" :X1="item.sell_count"></lang>
							</view>
							<view class="goods-name">{{goods.name}}</view>
							<view>{{currency + goods.price}}</view>
						</view>
					</view>
					<view class="price">
						<block v-if="item.discount_price > 0">
							<lang class="red" keywords="搭配可省"></lang>
							<text class="red">{{currency + item.discount_price}}</text>
						</block>
						<lang class="ml10 txt" keywords="实付"></lang>
						<text class="red">{{currency}}</text>
						<text class="red now-price">{{item.price}}</text>
						<view class="block-in" @click.stop="addPackGoods(item.com_id)">
							<lang class="btn ml10" :style="'background:' + mobile_head_color" keywords="立即购买"></lang>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- #ifdef H5 -->
		<view class="web-share" v-if="webShareTip" @tap="closeMask($event)" data-name="webShareTip">
			<image class="img" :src="requestDomain + 'static/images/share.png'" mode=""></image>
		</view>
		<!-- #endif -->
		

		<userinfo v-if="user_options" :options="user_options" @getUserscope="getUserInfo" @toLogin="getUserInfo"></userinfo>
		<miniNav v-if="navList.length > 0 && !hideMIniNav" :navList="navList"></miniNav>

		<view class="return-shop" @click="returnToShop" v-if="showReturnShop">
			<text class="iconfont icon-fanhui"></text>
			<lang keywords="回到店铺" chineseTxt="回到店铺"></lang>
		</view>
	</view>
</template>

<script>
import { expalinImg,explainIcon } from './m-explain-img.js'
import common from '../../../utils/common.js'
import head from '../../../utils/customHead.js'
import count from '../component/count/count'
import shopcart from '../component/shopcart/shopcart'
import goodsTip from '../component/goodsTip/goodsTip.vue'
import shopCommon from '../../../utils/shop/addToCart.js'
import miniNav from '../../../appComponent/platcommon/miniNav.vue'
var app = getApp();
var _this;
var price_width = 0;
var shareTxt1 = '推荐您一个好东西';
var shareTxt2 = '有人一起拼单吗？';
var goodsInfoObj = {};
var goodsObj = {};

export default {
	data() {
		return {
			mtype:[],
			showExplainImg:false,
			explainIcon,
			expalinImg,
			shopFrontColor: 'ffffff',
			shopBackgroundColor: '113533',
			imageHeight: 375,
			scrollTop: '',
			storeInfo: '',
			store: {},
			store_id: '',
			product_id: '',
			goodsInfo: '',
			goods: {
				specId: '',
				// 所选规格拼接字符串
				spec_list: [],
				// 当前选择的规格信息
				spec_text: '',
				propId: '',
				// 所选属性拼接字符串
				prop_list: [],
				// 当前选择的属性信息
				prop_text: '',
				goods_text: ''
			},
			// 当前准备加入购物车的商品信息
			goodsKeyList: {},
			goodsSpecList: {},
			// 当前加入购物车的同一规格的商品数量
			isShare: 0,
			// 标记是拼单发起人还是被邀请人
			orderStatus: 0,
			// 0是正常购买，1是拼单购买
			showShare: false,
			// 显示分享按钮
			showPoster: false,
			// 显示海报
			showDesc: false,
			// 显示结算说明
			width: 0,
			height: 0,
			max_height: 0,
			canSave: true,
			posterUrl: '',
			refresh: false,
			// true 表示页面需要刷新
			showHomeIcon: false,
			// 左上角是否显示home图标
			isNewHeader: true,
			// 是否支持自定义标题栏
			subsidiaryGoods: {
				money: 0
			},
			// 已选中的附属菜商品
			totalMoney: 0,
			// 有附属菜时显示的总价
			showSpecMask: false,
			// 附属菜 是否显示规格选择弹窗
			specGoods: {
				specId: '',
				// 所选规格拼接字符串
				spec_list: [],
				// 当前选择的规格信息
				spec_text: '',
				propId: '',
				// 所选属性拼接字符串
				prop_list: [],
				// 当前选择的属性信息
				prop_text: '',
				goods_text: ''
			},
			specGoodsInfo: {},
			showSpecNumMask: false, // 附属菜 是否显示已选规格弹窗
			phoneInfo: '',
			mobile_head_color: '',
			show_age: false,
			age_status: '',
			needLogin: false,
			specIndex: '',
			propIndex: '',
			specHeight: 0,
			requestDomain: common.requestDomain,
			webShareTip: false, // H5分享弹窗提示
			showCartComponent: true,
			
			
			user_options: '',
			refreshCart: false, // 通知购物车更新
			refreshCount: false, // 通知计数器更新
			currency: '¥',
			showPackMeal: false, // 是否显示组合套餐弹窗
			navList: [],
			showReturnShop: false, // 是否显示回到店铺按钮
			hideMIniNav: true,
		};
	},

	onShareAppMessage() {
		_this.showPoster = false;
		_this.showShare = false;
		/* let pageLink = `/#/pages/shop_new/orderTogether/orderTogether?store_id=${_this.store_id}&backgroundColor=${_this.shopBackgroundColor}&frontColor=${
				_this.shopFrontColor}&nickname=${togetherId.nickname}&cartId=${togetherId.cartId}` */
		let pageLink = `/pages/plat_menu/index?store_id=${_this.store_id}&backgroundColor=${_this.shopBackgroundColor}&frontColor=${_this.shopFrontColor}&product_id=${_this.product_id}&type=goodsDetail`;
		pageLink = common.addShareParam(pageLink)
		console.log('分享--',pageLink)
		return {
			title: `[￥${_this.goodsInfo.price}元]/${_this.goodsInfo.unit}`+_this.goodsInfo.name,
			path: pageLink
		};
	},

	onUnload() {
		if (_this.refresh === '') {
			var pages = getCurrentPages();
			var prevPage = pages[pages.length - 2];
			prevPage.refresh = true;
		}
		_this.showCartComponent = false;
	},

	onShow() {
		if (!wx.getStorageSync('togetherId') && _this.isShare == 0) {
			_this.orderStatus = 0;
			_this.uid = '';
		}
		// 判断页面信息是否需要刷新
		if (_this.refresh === true) {
			// 获取商品信息
			getGoodsDetail();
			_this.refresh = '';
		}

		// #ifdef H5
		if (_this.goodsInfo) {
			setWxShare();
		}
		// #endif
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		_this = this;
		shareTxt1 = common.changeTxt(shareTxt1);
		shareTxt2 = common.changeTxt(shareTxt2);
		var pages = getCurrentPages();

		if (pages.length == 1) {
			_this.showHomeIcon = true;
		}
		// 是否识别小程序二维码打开
		if (options.scene) {
			var scene = decodeURIComponent(options.scene);
			var arrPara = scene.split('&');
			var arr = [];

			for (var i in arrPara) {
				arr = arrPara[i].split('=');

				_this[arr[0]] = arr[1];
			}
		} else {
			_this.product_id = options.product_id;
			_this.store_id = options.store_id;
		}
		// 是否拼单被邀请者打开
		if (options.isShare) {
			_this.isShare = options.isShare;
			_this.orderStatus = options.orderStatus;
		}
		// 是否是好友分享链接打开
		if (options.goodsShare) {
			_this.showReturnShop = true
		}
		
		if (app.globalData.storeInfo != null && app.globalData.storeInfo.store_id == this.store_id) {
			_this.storeInfo = app.globalData.storeInfo;
		}
		// 获取商品信息
		getGoodsDetail();

		if (options.frontColor && options.backgroundColor) {
			_this.shopFrontColor = options.frontColor;
			_this.shopBackgroundColor = options.backgroundColor;

			wx.setNavigationBarColor({
				frontColor: '#' + options.frontColor,
				backgroundColor: '#' + options.backgroundColor
			});
		}

		var phoneInfo = wx.getSystemInfoSync();
		// 附属菜规格弹窗的最大高度

		var specHeight = phoneInfo.windowHeight * 0.8 - 93;

		_this.phoneInfo = phoneInfo;
		_this.specHeight = specHeight
		
		common.getConfig(function(data){
			_this.mobile_head_color = data.config.mobile_head_color
			_this.currency = data.config.Currency_symbol
		})
		
		common.getTabBar(function(data){
			console.log('底部导航999999999999', data)
			_this.navList = data.list
		})
	},

	components: {
		count,
		goodsTip,
		shopcart,
		miniNav
	},
	methods: {
		toggleShowExplainImg(){
			this.showExplainImg = !this.showExplainImg 
		},
		returnToShop () {
			uni.redirectTo({
				url: '/pages/shop_new/shopDetail/shopDetail?store_id=' + _this.store_id
			});
		},
		addPackGoods (com_id) {
			common.post('Cart&a=addPackage', {store_id: _this.store_id, com_id: com_id}, function (data) {
				shopCommon.initCart().then(function(){
					_this.getGoods({action: 'updateCart'})
					wx.navigateTo({
						url: '/pages/shop_new/confirmOrder/newCart?store_id=' + _this.store_id
					});
				})
				
			}, _this, function (err) {
				console.log('添加组合套餐失败', err)
			})
		},
		getUserInfo (e) { },
		// 点击商品加减按钮
		getGoods(e) {

			console.log('商品详情页 getGoods', e)
			// 登录
			if (e.action == 'login') {
				_this.user_options = {
					toLogin: true,
					showWebMask: true
				}
			}
			
			// 打开规格商品弹窗
			if (e.action == 'openSpecMask') {
				_this.showSpecMask = true
				_this.specProductId = e.goodsId
				return 
			}
			
			// 关闭规格商品弹窗
			if (e.action == 'closeSpecMask') {
				_this.showSpecMask = false
				return
			}
			
			// 更新购物车
			if (e.action == 'updateCart') {
				_this.$nextTick(function(){
					_this.refreshCart = true
					_this.refreshCount = true
				})
				return
			}
			
			// 更新购物车结束
			if (e.action == 'updateCartOver') {
				_this.$nextTick(function(){
					_this.refreshCart = false
					_this.refreshCount = false
				})
				return
			}
			
			// 清空购物车
			if (e.action == 'clearCart') {
				_this.$nextTick(function(){
					_this.refreshCount = true
				})
				return
			}
		},

		// 选择规格
		selectSpec(e) {
			var specId = ''
			var propId = ''
			var spec_text = ''
			var index1 = e.currentTarget.dataset.index1
			var index2 = e.currentTarget.dataset.index2
			var goods = _this.goods
			var goodsInfo = _this.goodsInfo;
			
			// tag标记有规格的附属菜商品
			if (e.currentTarget.dataset.tag) {
				goods = _this.specGoods;
				goodsInfo = _this.specGoodsInfo;
			}

			goodsInfo.properties_list.map(item => {
				if (item.num == 1) {
					item.val_status.map((i, index) => {
						i[1] = index == 0 ? 0 : 1;
						return i;
					});
					var id = item.id_ + '_' + 0
					propId = propId == '' ? id : propId + '_' + id
				}
				return item;
			});
			goods.spec_list[index1] = goodsInfo.spec_list[index1].list[index2];

			for (var i = 0; i < goods.spec_list.length; i++) {
				var id = goods.spec_list[i].id_;
				specId = specId == '' ? id : specId + '_' + id
				spec_text = spec_text === '' ? goods.spec_list[i].name : spec_text + '、' + goods.spec_list[i].name;
			}

			if (goods.specId != '' && goods.propId != '') {
				goods.key = goodsInfo.goods_id + '_' + specId + '_' + propId;
				goods.goods_text = spec_text + '、' + goods.prop_text;
			} else {
				goods.key = goodsInfo.goods_id + '_' + specId + propId;
				goods.goods_text = spec_text + goods.prop_text;
			}
			
			goods.propId = propId
			goods.specId = specId;
			goods.spec_text = spec_text
			goods.product_price = goodsInfo.list[specId].price;
			goods.unit = goodsInfo.list[specId]['spec'][0]['spec_val_name']
			console.log('mgoodsInfo')
			console.log(goodsInfo.list)
			
			goods.o_price = goodsInfo.list[specId].old_price;
			goods.max_num = goodsInfo.list[specId].max_num;
			goods.stock = goodsInfo.list[specId].stock_num;

			if (!e.currentTarget.dataset.tag) {
				var totalMoney = (goods.product_price * 1 + _this.subsidiaryGoods.money * 1).toFixed(2) * 1;
				_this.goods = goods;
				_this.goodsInfo = goodsInfo;
				_this.totalMoney = totalMoney;
			} else {
				_this.specGoods = goods;
				_this.specGoodsInfo = goodsInfo;
			}
			
			console.log('55555555555555选择规格', goods);
			_this.$forceUpdate()
		},

		// 选择属性
		selectProp(e) {
			var index1 = e.currentTarget.dataset.index1;
			var index2 = e.currentTarget.dataset.index2;
			var goods = _this.goods;
			var goodsInfo = _this.goodsInfo;

			if (e.currentTarget.dataset.tag) {
				goods = _this.specGoods;
				goodsInfo = _this.specGoodsInfo;
			}

			var prop_list = goodsInfo.properties_list;
			var properties_list = prop_list[index1];
			var prop_text = '';

			if (goods.specId != '') {
				var num = goodsInfo.list[goods.specId].properties[index1].num;
			} else {
				var num = goodsInfo.properties_list[index1].num;
			}

			if (num == 1) {
				// 当前属性必选
				properties_list.val_status.map(item => (item[1] = 1));
				properties_list.val_status[index2][1] = 0;
			} else {
				// 当前属性可多选或不选
				var arr = properties_list.val_status.filter(item => item[1] == 0);
				if (arr.length == num) {
					if (properties_list.val_status[index2][1] == 1) {
						showToast(common.changeTxt('X1最多只能选择X2个', { X1: properties_list.name, X2: num }));
						return;
					}
				}
				properties_list.val_status[index2][1] = properties_list.val_status[index2][1] == 0 ? 1 : 0;
			}

			var propId = '';
			for (var i = 0; i < prop_list.length; i++) {
				var str = '';
				for (var j = 0; j < prop_list[i].val_status.length; j++) {
					if (prop_list[i].val_status[j][1] === 0) {
						str = str === '' ? j : str + '_' + j;
						prop_text = prop_text === '' ? prop_list[i].val_status[j][0] : prop_text + '、' + prop_list[i].val_status[j][0];
					}
				}
				str = str === '' ? str : prop_list[i].id_ + '_' + str;
				propId = propId === '' ? str : propId + '_' + str;
			}

			goodsInfo.properties_list.splice(index1, 1, properties_list);
			goods.propId = propId;
			goods.prop_text = prop_text;
			goods.prop_list = goodsInfo.properties_list;

			if (goods.specId != '' && goods.propId != '') {
				goods.key = goodsInfo.goods_id + '_' + goods.specId + '_' + goods.propId;
				goods.goods_text = goods.spec_text + '、' + goods.prop_text;
			} else {
				goods.key = goodsInfo.goods_id + '_' + goods.specId + goods.propId;
				goods.goods_text = goods.spec_text + goods.prop_text;
			}

			console.log('55555555555555选择规格', goods.prop_text);

			if (!e.currentTarget.dataset.tag) {
				_this.goodsInfo = goodsInfo;
				_this.goods = goods;
			} else {
				_this.specGoods = goods;
				_this.specGoodsInfo = goodsInfo;
			}
			_this.$forceUpdate()
		},

		// 打开弹窗
		clickShow(e) {
			// #ifdef H5
			if (e.currentTarget.dataset.name == 'showShare') {
				if (common.$checkPlat.checkWeixin()) {
					_this.webShareTip = true;
				} else {
					uni.showToast({
						icon: 'none',
						title: common.changeTxt('当前环境不支持分享')
					});
				}
				return
			}
			// #endif
			
			_this[e.currentTarget.dataset.name] = true;
			
			_this.$nextTick(function(){
				if (e.currentTarget.dataset.name == 'showPoster') {
					if (price_width == 0) {
						getClassNode('.price-mark, .price-num');	
					}
					
					if (_this.posterUrl !== true) {
						showToast(common.changeTxt('海报还未完成，请稍后再试！'));
						if (_this.posterUrl === false) {
							drowPoster();
						}
						return
					}
				}
			})
			
			if (e.currentTarget.dataset.name == 'showPackMeal' && _this.goodsInfo.combination_list.length <= 2) {
				return
			}
			
		},

		// 关闭弹窗
		closeMask(e) {
			var name = e.currentTarget.dataset.name;
			_this[name] = false;

			if (name == 'showPoster') {
				_this.showShare = false;
			} else if (name == 'showSpecMask') {
				_this.showSpecNumMask = false;
			}
		},

		// 保存图片
		savePoster() {
			console.log('savePoster', 'true');
			wx.getSetting({
				success: function(res) {
					//不存在相册授权
					if (res.authSetting['scope.writePhotosAlbum'] == undefined || res.authSetting['scope.writePhotosAlbum'] == true) {
						saveImg();
					} else if (res.authSetting['scope.writePhotosAlbum'] == false) {
						_this.canSave = false;
					}
				}
			});
		},

		// 打开授权设置
		handleSetting(e) {
			if (e.detail.authSetting['scope.writePhotosAlbum'] == true) {
				saveImg();
				_this.canSave = true;
			}
		},

		// 查看大图
		previewImg(e) {
			var pic_arr = _this.goodsInfo.pic_arr.map(item => item.url);
			wx.previewImage({
				current: pic_arr[e.currentTarget.dataset.index],
				// 当前显示图片的http链接
				urls: pic_arr // 需要预览的图片http链接列表
			});
		},

		// 附属菜 选择其它
		selectOther() {
			var subsidiaryGoods = _this.subsidiaryGoods;
			var parentsGoods = _this.parentsGoods;
			if (parentsGoods.maxnum > 0 && parentsGoods.selectNum == parentsGoods.maxnum * 1) {
				showToast(common.changeTxt('X1最多只能选择X2份！', { X1: parentsGoods.name, X2: parentsGoods.maxnum }));
				return;
			}
			if (parentsGoods.goods.maxnum_sug > 0 && subsidiaryGoods[parentsGoods.goods.goods_id].selectNum == parentsGoods.goods.maxnum_sug * 1) {
				showToast(common.changeTxt('X1最多只能选择X2份', { X1: parentsGoods.goods.name, X2: parentsGoods.goods.maxnum_sug }));
				return;
			}
			_this.showSpecNumMask = false;
		},

		// 附属菜 规格商品  列表加
		addSpec(e) {
			var index = e.currentTarget.dataset.index;
			var specGoods = _this.specGoods;
			var subsidiaryGoods = _this.subsidiaryGoods;
			var parentsGoods = _this.parentsGoods;

			if (parentsGoods.maxnum > 0 && parentsGoods.selectNum == parentsGoods.maxnum * 1) {
				showToast(common.changeTxt('X1最多只能选择X2份！', { X1: parentsGoods.name, X2: parentsGoods.maxnum }));
				return;
			}

			if (specGoods.stock > 0 && specGoods.selectNum == specGoods.stock * 1) {
				showToast(common.changeTxt('X1已达库存上限', { X1: specGoods.product_name + '（' + specGoods.goods_text + '）' }));
				return;
			}

			if (parentsGoods.goods.maxnum_sug > 0 && subsidiaryGoods[specGoods.product_id].selectNum == parentsGoods.goods.maxnum_sug * 1) {
				showToast(common.changeTxt('X1最多只能选择X2份', { X1: parentsGoods.goods.name, X2: parentsGoods.goods.maxnum_sug }));
				return;
			}

			parentsGoods.selectNum += 1;
			subsidiaryGoods[specGoods.product_id].list[index].selectNum += 1;
			subsidiaryGoods[specGoods.product_id].money += subsidiaryGoods[specGoods.product_id].list[index].product_price * 1;
			subsidiaryGoods[specGoods.product_id].selectNum += 1;
			subsidiaryGoods.money += subsidiaryGoods[specGoods.product_id].list[index].product_price * 1;
			_this.totalMoney += subsidiaryGoods[specGoods.product_id].list[index].product_price * 1;
			_this.totalMoney = _this.totalMoney.toFixed(2) * 1;
			var desc_text = '';

			for (var i = 0; i < subsidiaryGoods[specGoods.product_id].list.length; i++) {
				var item = subsidiaryGoods[specGoods.product_id].list[i];
				var currencySymbol = app.globalData.config.config.Currency_symbol && app.globalData.open_multilingual ? app.globalData.config.config.Currency_symbol : '￥';
				desc_text += '(' + item.goods_text + ')×' + item.selectNum + ' +' + currencySymbol + item.product_price;

				if (i < subsidiaryGoods[specGoods.product_id].list.length - 1) {
					desc_text += '，';
				}
			}

			subsidiaryGoods[specGoods.product_id].desc_text = desc_text;

			_this.goodsInfo.subsidiary_piece[parentsGoods.listIndex].goods[parentsGoods.index].selectNum = subsidiaryGoods[specGoods.product_id].selectNum;
			_this.goodsInfo.subsidiary_piece[parentsGoods.listIndex].selectNum = parentsGoods.selectNum;
			_this.subsidiaryGoods = subsidiaryGoods;

			// #ifdef MP-WEIXIN
			var goodsStr = `goodsInfo.subsidiary_piece[${parentsGoods.listIndex}].goods[${parentsGoods.index}].selectNum`;
			var parentsStr = `goodsInfo.subsidiary_piece[${parentsGoods.listIndex}].selectNum`;
			_this.setData({
				[goodsStr]: subsidiaryGoods[specGoods.product_id].selectNum,
				[parentsStr]: parentsGoods.selectNum,
				totalMoney: _this.totalMoney,
				subsidiaryGoods: subsidiaryGoods
			});
			// #endif
		},

		// 附属菜 规格商品  列表减
		subSpec(e) {
			var specGoods = _this.specGoods;
			var index = e.currentTarget.dataset.index;
			var subsidiaryGoods = _this.subsidiaryGoods;
			var parentsGoods = _this.parentsGoods;
			parentsGoods.selectNum -= 1;
			subsidiaryGoods[specGoods.product_id].selectNum -= 1;
			subsidiaryGoods[specGoods.product_id].list[index].selectNum -= 1;
			subsidiaryGoods[specGoods.product_id].money -= subsidiaryGoods[specGoods.product_id].list[index].product_price * 1;
			subsidiaryGoods.money -= subsidiaryGoods[specGoods.product_id].list[index].product_price * 1;
			_this.totalMoney -= subsidiaryGoods[specGoods.product_id].list[index].product_price * 1;
			_this.totalMoney = _this.totalMoney.toFixed(2) * 1;

			if (subsidiaryGoods[specGoods.product_id].list[index].selectNum === 0) {
				subsidiaryGoods[specGoods.product_id].list.splice(index, 1);
			}

			var num = subsidiaryGoods[specGoods.product_id].selectNum;

			if (subsidiaryGoods[specGoods.product_id].selectNum === 0) {
				num = 0;
				delete subsidiaryGoods[specGoods.product_id];

				(_this.showSpecMask = false), (_this.showSpecNumMask = false);
			}

			_this.goodsInfo.subsidiary_piece[parentsGoods.listIndex].goods[parentsGoods.index].selectNum = num;
			_this.goodsInfo.subsidiary_piece[parentsGoods.listIndex].selectNum = parentsGoods.selectNum;
			_this.subsidiaryGoods = subsidiaryGoods;

			// #ifdef MP-WEIXIN
			var goodsStr = `goodsInfo.subsidiary_piece[${parentsGoods.listIndex}].goods[${parentsGoods.index}].selectNum`;
			var parentsStr = `goodsInfo.subsidiary_piece[${parentsGoods.listIndex}].selectNum`;

			_this.setData({
				[goodsStr]: num,
				[parentsStr]: parentsGoods.selectNum,
				totalMoney: _this.totalMoney,
				subsidiaryGoods: subsidiaryGoods
			});
			// #endif
		},

		// 附属菜 规格商品 弹窗 加
		addSubsidiary() {
			
			var specGoods = JSON.parse(JSON.stringify(_this.specGoods));
			var parentsGoods = _this.parentsGoods;
			var subsidiaryGoods = _this.subsidiaryGoods;

			if (specGoods.stock_num == 0) {
				console.log('111111')
				showToast(common.changeTxt('X1已售罄', { X1: specGoods.product_name }));
				return;
			}
			if (specGoods.stock_num > 0 && specGoods.selectNum == specGoods.stock_num * 1) {
				console.log('111111')
				showToast(common.changeTxt('X1已达库存上限', { X1: specGoods.product_name + '（' + specGoods.goods_text + '）' }));
				return;
			}
			// 已选的附属菜商品列表中不存在该商品
			if (!subsidiaryGoods[specGoods.product_id]) {
				_this.specGoods.selectNum = 1;
				specGoods.selectNum = 1;
				subsidiaryGoods[specGoods.product_id] = parentsGoods.goods;
				subsidiaryGoods[specGoods.product_id].list = [];
				subsidiaryGoods[specGoods.product_id].list.push(specGoods);
				subsidiaryGoods[specGoods.product_id].money = 0;
			} else {
				var is_have = false;
				for (var i = 0; i < subsidiaryGoods[specGoods.product_id].list.length; i++) {
					if (subsidiaryGoods[specGoods.product_id].list[i].key == specGoods.key) {
						is_have = true;
						subsidiaryGoods[specGoods.product_id].list[i].selectNum += 1;
						_this.specGoods.selectNum++;
						break;
					}
				}

				if (!is_have) {
					// 不存在该规格
					specGoods.selectNum = 1;
					_this.specGoods.selectNum = 1;
					if (_this.specGoodsInfo.list) var arr = {};
					var sort = 0;
					for (var i in _this.specGoodsInfo.list) {
						arr[i] = sort;
						sort++;
					}
					if (arr[specGoods.specId] <= subsidiaryGoods[specGoods.product_id].list.length) {
						subsidiaryGoods[specGoods.product_id].list.splice(arr[specGoods.specId], 0, specGoods);
					} else {
						subsidiaryGoods[specGoods.product_id].list.push(specGoods);
					}
				}
			}

			var desc_text = '';

			for (var i = 0; i < subsidiaryGoods[specGoods.product_id].list.length; i++) {
				var item = subsidiaryGoods[specGoods.product_id].list[i];
				var currencySymbol = app.globalData.config.config.Currency_symbol && app.globalData.open_multilingual ? app.globalData.config.config.Currency_symbol : '￥';
				desc_text += '(' + item.goods_text + ')×' + item.selectNum + ' +' + currencySymbol + item.product_price;
				if (i < subsidiaryGoods[specGoods.product_id].list.length - 1) {
					desc_text += '，';
				}
			}

			subsidiaryGoods[specGoods.product_id].desc_text = desc_text;
			parentsGoods.selectNum += 1;
			subsidiaryGoods[specGoods.product_id].selectNum += 1;
			subsidiaryGoods.money += specGoods.product_price * 1;
			subsidiaryGoods[specGoods.product_id].money += specGoods.product_price * 1;
			_this.totalMoney += specGoods.product_price * 1;
			_this.totalMoney = _this.totalMoney.toFixed(2) * 1;
			var goodsStr = `goodsInfo.subsidiary_piece[${parentsGoods.listIndex}].goods[${parentsGoods.index}].selectNum`;
			var parentsStr = `goodsInfo.subsidiary_piece[${parentsGoods.listIndex}].selectNum`;

			_this.goodsInfo.subsidiary_piece[parentsGoods.listIndex].goods[parentsGoods.index].selectNum = subsidiaryGoods[specGoods.product_id].selectNum;
			_this.goodsInfo.subsidiary_piece[parentsGoods.listIndex].selectNum = parentsGoods.selectNum;
			_this.showSpecMask = false;
			_this.subsidiaryGoods = subsidiaryGoods;
		},

		// 附属菜 加
		subsidiaryAdd(e) {
			if (!isCanBuy()) {
				_this.subsidiaryAddInfo = e;
				return;
			}
			// 判断当前规格商品是否达到限购数量
			if (!_this.goodsInfo.is_seckill_price && _this.goods.max_num > 0 && _this.goodsSpecList[_this.goods.specId] == _this.goods.max_num) {
				showToast(
					common.changeTxt('X1最多只能购买X2份！', {
						X1: _this.goods.product_name + '(' + _this.goods.spec_text + ')',
						X2: _this.goods.max_num
					})
				);
				return;
			}

			var listIndex = e.currentTarget.dataset.listindex;
			var index = e.currentTarget.dataset.index;
			var parentsGoods = JSON.parse(JSON.stringify(_this.goodsInfo.subsidiary_piece[listIndex]));
			var goods = parentsGoods.goods[index]; 
			goods.realIndex = listIndex + index
			
			// 判断所属分类商品的选择总数
			if (!parentsGoods.selectNum) {
				parentsGoods.selectNum = 0;
			}

			if (parentsGoods.maxnum > 0 && parentsGoods.selectNum == parentsGoods.maxnum * 1) {
				showToast(common.changeTxt('X1最多只能选择X2份！', { X1: parentsGoods.name, X2: parentsGoods.maxnum }));
				return;
			} 
			// 判断商品是否已达到最大选择数量
			if (!goods.selectNum) {
				goods.selectNum = 0;
			} 
			// 判断当前商品库存
			if (goods.stock_num == 0) {
				showToast(
					common.changeTxt('X1已售罄！', {
						X1: goods.name
					})
				);
				return;
			}

			if (goods.stock_num > 0 && goods.selectNum == goods.stock_num * 1) {
				showToast(
					common.changeTxt('X1已达库存上限', {
						X1: goods.name
					})
				);
				return;
			} 
			// 判断商品最大选择数量
			if (goods.maxnum_sug > 0 && goods.selectNum == goods.maxnum_sug) {
				showToast(
					common.changeTxt('X1最多只能选择X2份！', {
						X1: goods.name,
						X2: goods.maxnum_sug
					})
				);
				return;
			} 
			// 判断商品是否有规格
			if (goods.spec_value != '') {
				getSubsidiaryGoods(goods.goods_id);
				parentsGoods.listIndex = listIndex;
				parentsGoods.index = index;
				parentsGoods.goods = goods;
				_this.parentsGoods = parentsGoods;
				return;
			}
			
			goods.selectNum += 1;
			parentsGoods.selectNum += 1;
			_this.subsidiaryGoods.money += goods.price_sug * 1;
			_this.subsidiaryGoods[goods.goods_id] = goods;
			_this.totalMoney += goods.price_sug * 1;
			_this.totalMoney = _this.totalMoney.toFixed(2) * 1;
			var goodsStr = `goodsInfo.subsidiary_piece[${listIndex}].goods[${index}].selectNum`;
			var parentsStr = `goodsInfo.subsidiary_piece[${listIndex}].selectNum`;

			_this.goodsInfo.subsidiary_piece[listIndex].goods[index].selectNum = goods.selectNum;
			_this.goodsInfo.subsidiary_piece[listIndex].selectNum = parentsGoods.selectNum;
			
			_this.$forceUpdate()
		},

		// 附属菜 减
		subsidiarySub(e) {
			var listIndex = e.currentTarget.dataset.listindex;
			var index = e.currentTarget.dataset.index;
			var parentsGoods = JSON.parse(JSON.stringify(_this.goodsInfo.subsidiary_piece[listIndex]));
			var goods = parentsGoods.goods[index]; 
			// 判断商品是否有规格

			if (goods.spec_value != '') {
				getSubsidiaryGoods(goods.goods_id);
				parentsGoods.listIndex = listIndex;
				parentsGoods.index = index;
				parentsGoods.goods = goods;
				_this.parentsGoods = parentsGoods;
				return;
			}

			var sub_num = 0;

			if (goods.selectNum <= goods.mininum_sug) {
				sub_num = goods.selectNum;
			} else {
				sub_num = 1;
			}

			parentsGoods.selectNum -= sub_num;
			goods.selectNum -= sub_num;
			_this.subsidiaryGoods.money -= goods.price_sug * sub_num;
			_this.totalMoney -= goods.price_sug * sub_num;
			_this.totalMoney = _this.totalMoney.toFixed(2) * 1;

			if (goods.selectNum === 0) {
				delete _this.subsidiaryGoods[goods.goods_id];
			} else {
				_this.subsidiaryGoods[goods.goods_id] = goods;
			}

			_this.goodsInfo.subsidiary_piece[listIndex].goods[index].selectNum = goods.selectNum;
			_this.goodsInfo.subsidiary_piece[listIndex].selectNum = parentsGoods.selectNum;

			// #ifdef MP-WEIXIN
			var goodsStr = `goodsInfo.subsidiary_piece[${listIndex}].goods[${index}].selectNum`;
			var parentsStr = `goodsInfo.subsidiary_piece[${listIndex}].selectNum`;

			_this.setData({
				[goodsStr]: goods.selectNum,
				[parentsStr]: parentsGoods.selectNum,
				totalMoney: _this.totalMoney
			});
			// #endif
			
			_this.$forceUpdate()
		},

		// 附属菜 加入购物车
		addToCart() {
			// 判断当前规格商品是否达到限购数量
			if (!_this.goodsInfo.is_seckill_price && _this.goods.max_num > 0 && _this.goodsSpecList[_this.goods.specId] == _this.goods.max_num) {
				showToast(
					common.changeTxt('X1最多只能购买X2份！', {
						X1: _this.goods.product_name + '（' + _this.goods.spec_text + '）',
						X2: _this.goods.max_num
					})
				);
				return;
			}

			var list = _this.goodsInfo.subsidiary_piece;

			for (var i = 0; i < list.length; i++) {
				for (var j = 0; j < list[i].goods.length; j++) {
					var item = list[i].goods[j];

					if (!item.selectNum) {
						item.selectNum = 0;
					}

					if (item.mininum_sug > 0 && item.selectNum < item.mininum_sug * 1) {
						_this.scrollTop = _this.subgoods_top['sub-goods-' + item.goods_id];
						showToast(common.changeTxt('X1最少需要选择X2份！', { X1: item.name, X2: item.mininum_sug }));
						return;
					}
				}

				if (list[i].mininum > 0 && (!list[i].selectNum || list[i].selectNum < list[i].mininum)) {
					_this.scrollTop = _this.subgoods_top['sub-goods-' + list[i].id_sp];
					showToast(common.changeTxt('X1最少需要选择X2份！', { X1: list[i].name, X2: list[i].mininum }));
					return;
				}
			}

			if (_this.goodsInfo.subsidiary_piece.length > 0) {
				var subsidiaryGoods = _this.subsidiaryGoods;
				var subsidiary_text = '';
				var key = _this.goods.product_id;
				var arr = []
				
				for (let i in subsidiaryGoods) {
					if (i != 'money' ) {
						arr.push(subsidiaryGoods[i])
					}
				}
				arr.sort(sortBy('realIndex'))

				if (_this.goods.specId) {
					key += '_' + _this.goods.specId;
				}

				if (_this.goods.propId) {
					key += '_' + _this.goods.propId;
				}

				for (var i in arr) {
					if (arr[i].list) {
						arr[i].list.map((item, index) => {
							subsidiary_text += '，' + arr[i].name + '(' + item.goods_text + ')×' + item.selectNum;
							key += '_' + item.key + '_' + item.selectNum;
						});
					} else if (i != 'money') {
						key += '_' + arr[i].goods_id + '_' + arr[i].selectNum;
						subsidiary_text += '，' + arr[i].name + '×' + arr[i].selectNum;
					}
				}

				if (_this.goodsInfo.spec_list.length == 0) {
					subsidiary_text = subsidiary_text.slice(1, subsidiary_text.length);
				}
				
				_this.goods.key = key;
				_this.goods.subsidiary_text = subsidiary_text;
				_this.goods.subsidiary_list = arr;
				_this.goods.totalMoney = _this.totalMoney;
			}
			let param = {}
			if (app.globalData.storeGoods && app.globalData.storeGoods.KeyList && app.globalData.storeGoods.KeyList[_this.goods.key]) {
				param = {
					"store_id": app.globalData.storeInfo.store_id,
					"uniqueness_number": _this.goods.key,
					"number": app.globalData.storeGoods.KeyList[_this.goods.key] + 1
				}
			} else {
				param = {
					store_id: app.globalData.storeInfo.store_id,
					product: [{
						"productId": _this.goods.product_id,
						"host_goods_id": 0,
						"uniqueness_number": _this.goods.key,
						"productName": _this.goods.product_name,
						"productPrice": _this.goods.product_price,
						"count": 1,
						"productParam": shopCommon.getSpecParam(_this.goods)
					}]
				}
				for (var i in arr) {
					if (arr[i].list) {
						arr[i].list.map(item => {
							console.log('2222', item)
							param.product.push({
								"productId": item.product_id,
								"host_goods_id": _this.goods.product_id,
								"uniqueness_number": _this.goods.key,
								"productName": item.product_name,
								"productPrice": item.product_price,
								"count": item.selectNum,
								"productParam": shopCommon.getSpecParam(item)
							})
							return item
						})
					} else {
						param.product.push({
							"productId": arr[i].goods_id,
							"host_goods_id": _this.goods.product_id,
							"uniqueness_number": _this.goods.key,
							"productName": arr[i].name,
							"productPrice": arr[i].price,
							"count": arr[i].selectNum,
							"productParam": shopCommon.getSpecParam(arr[i])
						})
					}
				}
				console.log('111111附属菜', param)
			}
			shopCommon.updateCart(param).then(function(data){
				console.log('更新购物车数据成功的回调', data)
				_this.getGoods({action: 'updateCart'})
			})
			// 重置页面数据
			var obj = {
				specId: '',
				// 所选规格拼接字符串
				spec_list: [],
				// 当前选择的规格信息
				spec_text: '',
				propId: '',
				// 所选属性拼接字符串
				prop_list: [],
				// 当前选择的属性信息
				prop_text: '',
				goods_text: ''
			};
			var goods = JSON.parse(JSON.stringify(goodsObj));
			var goodsInfo = JSON.parse(JSON.stringify(goodsInfoObj));

			_this.subsidiaryGoods = {
				money: 0
			};
			_this.specGoods = obj;
			_this.specGoodsInfo = {};
			_this.goods = obj;
			_this.goodsInfo = goodsInfo;
			_this.goods = goods;
			_this.totalMoney = goods.product_price * 1;
			_this.showSpecMask = false;
			_this.showSpecNumMask = false;
			_this.$forceUpdate()
		},

		noclose() {}
	}
};

const sortBy = (props) => {
    return function(a,b) {
        return a[props]*1 - b[props]*1
    }
}

// 获取有规格的附属菜
const getSubsidiaryGoods = goods_id => {
	if (_this.subsidiaryGoods[goods_id] && goods_id == _this.specGoods.product_id) {
		_this.showSpecMask = true;
		_this.showSpecNumMask = true;

		return;
	}

	var specGoods = {
		specId: '',
		// 所选规格拼接字符串
		spec_list: [],
		// 当前选择的规格信息
		spec_text: '',
		propId: '',
		// 所选属性拼接字符串
		prop_list: [],
		// 当前选择的属性信息
		prop_text: '',
		goods_text: ''
	};
	common.post(
		'Shop_new&a=ajax_goods',
		{
			goods_id
		},
		data => {
			if (data) {
				calcGoodsSpec(data, specGoods);
				_this.specGoodsInfo = data;
				_this.specGoods = specGoods;

				if (_this.subsidiaryGoods[goods_id]) {
					_this.showSpecMask = true;
					_this.showSpecNumMask = true;
				} else {
					_this.showSpecMask = true;
				}
			}
		}
	);
}; 
// 获取商品信息
const getGoodsDetail = () => {
	var goods = _this.goods;
	var param = {
		goods_id: _this.product_id
	};
	common.post('Shop_new&a=ajax_goods', param, data => {
		if (data) {
			console.log('yjy')
			console.log(data)
			if(data.name){
				_this.mtype.push('商品名称：'+ data.name)
			}
			
			if(data.mproduct){
				_this.mtype.push('产品名称：'+ data.mproduct)
			}
			
			if(data.mweight){
				_this.mtype.push('产品重量：'+ data.mweight)
			}
			
			if(data.marea){
				_this.mtype.push('原产地：'+ data.marea)
			}
			
			if(data.mtime){
				_this.mtype.push('保质期：'+ data.mtime)
			}
			
			if(data.mcount){
				_this.mtype.push('包装数量：'+ data.mcount)
			}
			
			// if(data.mtype){
			// 	_this.mtype = data.mtype.split('\n')	
			// }
			
			if (data.des != '') {
				data.des = data.des.replace(/<img style="/g, '<img style="vertical-align: top; ');
			} 
			// 计算有规格商品打折的折扣

			for (var i in data.list) {
				if (data.list[i].index) {
					data.list[i].seckill_discount = ((data.list[i].price / data.list[i].old_price) * 10).toFixed(2);
				}
			}

			calcGoodsSpec(data, goods);
			goodsInfoObj = JSON.parse(JSON.stringify(data));
			goodsObj = JSON.parse(JSON.stringify(goods));

			_this.goodsInfo = data;
			_this.goods = goods;
			_this.totalMoney = goods.product_price * 1;
			uni.getImageInfo({
				src: data.image,
				success: function(image) {
					_this.goodsImageInfo = image;
					var imageHeight = ((_this.phoneInfo.windowWidth * image.height) / image.width).toFixed(2);

					if (imageHeight > _this.phoneInfo.windowWidth) {
						imageHeight = _this.phoneInfo.windowWidth;
					}
					_this.imageHeight = imageHeight;
				},
				complete: function() {
					if (data.subsidiary_piece.length > 0) {
						wx.createSelectorQuery()
							.selectAll('.sub-goods')
							.boundingClientRect(function(rects) {
								console.log('3333333', rects);

								if (rects) {
									var subgoods_top = {};
									rects.map(item => {
										subgoods_top[item.id] = item.top - _this.totalH;
									});
									_this.subgoods_top = subgoods_top;
								}
							})
							.exec();
					}

					if (_this.storeInfo == '') {
						getShopInfo();
					} else {
						// #ifdef MP-WEIXIN || MP-ALIPAY
						drowPoster();
						// #endif

						// #ifdef H5
						console.log('商品详情页设置分享aaa');
						setWxShare();
						// #endif
						
						if (app.globalData.is_login) {
							shopCommon.initCart().then(function(data){
								if (data) {
									_this.selectType = data.sort_num
								} else {
									_this.selectType = {}
								}
								_this.getGoods({action: 'updateCart'})
							})
						}
					}
				}
			});
		}
	});
};
const calcGoodsSpec = (data, goods) => {
	// 商品有规格的时候
	if (data.spec_list.length > 0) {
		var specId = '';

		for (var i = 0; i < data.spec_list.length; i++) {
			var id = data.spec_list[i].list[0].id_;

			if (i > 0) {
				id = '_' + id;
			}

			specId = specId + id;
			goods.spec_list[i] = data.spec_list[i].list[0];
			goods.spec_text = goods.spec_text === '' ? data.spec_list[i].list[0].name : goods.spec_text + ' ' + data.spec_list[i].list[0].name;
		}

		goods.specId = specId;
	}
	// 商品有属性的时候
	if (data.properties_list.length > 0) {
		var propId = '';

		for (var i = 0; i < data.properties_list.length; i++) {
			
			if (data.properties_list[i].num == 1) {
				data.properties_list[i].val_status[0][1] = 0;
				var id = data.properties_list[i].id_ + '_' + 0;
				propId = propId === '' ? id : propId + '_' + id;
				goods.prop_text = goods.prop_text === '' ? data.properties_list[i].val[0] : goods.prop_text + ' ' + data.properties_list[i].val[0];
			}
		}

		goods.propId = propId;
		goods.prop_list = data.properties_list;
	}

	goods.product_id = data.goods_id;
	goods.product_name = data.name;
	goods.is_seckill_price = data.is_seckill_price;
	goods.packing_charge = data.packing_charge;
	goods.unit = data.unit;
	goods.min_num = data.min_num;
	goods.sort_id = data.sort_id;
	goods.product_image = data.image;
	goods.is_subsidiary_goods = data.is_subsidiary_goods
	goods.product_sale = data.sell_count
	goods.has_format = data.properties_list && data.properties_list.length > 0  ? true : true
	
	
	if (data.spec_list.length == 0) {
		// 商品没有规格的时候
		goods.key = data.goods_id;
		goods.product_price = data.price;
		goods.o_price = data.o_price;
		goods.max_num = data.max_num;
		goods.stock = data.stock_num;
		goods.seckill_stock = data.seckill_stock;
		goods.has_spec = false
	} else {
		if (goods.specId != '' && goods.propId != '') {
			goods.key = data.goods_id + '_' + goods.specId + '_' + goods.propId
			goods.goods_text = goods.spec_text + '、' + goods.prop_text
		} else {
			goods.key = data.goods_id + '_' + goods.specId + goods.propId
			goods.goods_text = goods.spec_text + goods.prop_text
		}
		goods.product_price = goods.specId == '' ? data.price : data.list[goods.specId].price;
		goods.o_price = goods.specId == '' ? data.o_price : data.list[goods.specId].old_price;
		goods.max_num = goods.specId == '' ? data.max_num : data.list[goods.specId].max_num;
		goods.stock = goods.specId == '' ? data.stock_num : data.list[goods.specId].stock_num;
		goods.seckill_stock = goods.specId == '' ? data.seckill_stock : data.list[goods.specId].stock_num;
		goods.has_spec = true
	}
}; 
// 判断年龄和关店
const isCanBuy = () => {
	if (_this.storeInfo.is_close == 1) {
		showToast(common.changeTxt('店铺休息中'));
		return false;
	}

	if (_this.storeInfo.check_age_object.check_age) {
		var ticket = wx.getStorageSync('ticket');

		if (!ticket || !app.globalData.userInfo) {
			_this.needLogin = true;

			return false;
		} else {
			var user_age = app.globalData.userInfo.age * 1;
			var limit_age = _this.storeInfo.check_age_object.age_limit_buy * 1; // 生日未知

			if (user_age <= 0) {
				_this.age_status = 1;
				_this.show_age = true;

				return false;
			} // 生日小于限制年龄

			if (user_age < limit_age) {
				_this.age_status = 2;
				_this.show_age = true;

				return false;
			}

			return true;
		}
	}

	return true;
};
const getShopInfo = () => {
	common.post(
		'Shop_new&a=ajax_shop',
		{
			store_id: _this.store_id
		},
		data => {
			if (data) {
				wx.setNavigationBarColor({
					frontColor: '#' + data.shop_fitment_front_color,
					backgroundColor: '#' + data.shop_fitment_color
				});
				app.globalData.storeInfo = data;

				_this.storeInfo = data;
				_this.shopFrontColor = data.shop_fitment_front_color;
				_this.shopBackgroundColor = data.shop_fitment_color;

				// #ifdef MP-WEIXIN || MP-ALIPAY
				drowPoster();
				// #endif

				// #ifdef H5
				console.log('商品详情页设置分享bbb');
				setWxShare();
				// #endif
				
				if (app.globalData.is_login) {
					shopCommon.initCart().then(function(data){
						if (data) {
							_this.selectType = data.sort_num
						} else {
							_this.selectType = {}
						}
						_this.getGoods({action: 'updateCart'})
					})
				}
			}
		}
	);
};
const setWxShare = () => {
	try {
		let pageLink = `${common.requestDomain}packapp/${common.wxapp_type}/pages/shop_new/goodsDetail/goodsDetail?store_id=${_this.store_id}&backgroundColor=${_this.shopBackgroundColor}&frontColor=${_this.shopFrontColor}&product_id=${_this.product_id}`;
		let shareWxLink = common.addShareParam(pageLink)
		var shareData = {
			title: `${shareTxt1}「 ${_this.goodsInfo.name}-${_this.storeInfo.name} 」`,
			desc: _this.storeInfo.txt_info,
			sendFriendLink: shareWxLink,
			share_img: _this.goodsInfo.image
		};
		common.setWxShare(shareData);
	} catch (e) {
		console.log('商品详情页设置分享报错', e);
	}
};
const drowPoster = () => {
	var shop = _this.storeInfo;
	var goods = _this.goodsInfo;
	var ctx = wx.createCanvasContext('pubShare');
	var system = _this.phoneInfo;
	var logo = _this.goodsImageInfo;

	if (!logo) {
		_this.posterUrl = false;
		return;
	}

	var width = system.windowWidth;
	var imageH = ((width - 20) * _this.imageHeight) / width;
	var height = imageH + 165;
	var max_height = system.windowHeight;
	logo.height = imageH;

	_this.width = width;
	_this.height = height;
	_this.max_height = max_height;
	// 绘制背景
	ctx.fillStyle = 'white';
	ctx.fillRect(0, 0, width, height); // 商品图片

	ctx.drawImage(logo.path, 10, 10, width - 20, imageH); // 商品名称

	ctx.setFontSize(16);
	ctx.fillStyle = '#000000';
	ctx.setTextAlign('left');
	var max_width = width - 80;
	var num = Math.floor(max_width / 16);
	var str1 = goods.name.slice(0, num + 1);
	var str2 = goods.name.slice(num + 1, num * 2 - 2);
	var y = logo.height + 35;
	var currencySymbol = app.globalData.config.config.Currency_symbol && app.globalData.open_multilingual ? app.globalData.config.config.Currency_symbol : '￥';
	ctx.fillText(str1, 10, y);

	if (str2 != '') {
		y = y + 20;
		str2 = goods.name.length >= num * 2 - 2 ? str2 + '...' : str2;
		ctx.fillText(str2, 10, y);
	} // 店铺名称

	ctx.setFontSize(12);
	ctx.fillStyle = '#666666';
	ctx.setTextAlign('left');
	var m_width = width - 120;
	var n = Math.floor(m_width / 12);
	var str3 = shop.name.slice(0, n + 1);
	var str4 = shop.name.slice(n + 1, n * 2 - 2);
	y = y + 20;
	ctx.fillText(str3, 10, y);

	if (str4 != '') {
		y = y + 15;
		ctx.fillText(str4, 10, y);
	} // 评分星星

	for (let i = 0; i < 5; i++) {
		if (shop.star - i > 1) {
			ctx.drawImage('../../../static/images/sn_total.png', 10 + 12 * i, y + 5, 10, 9.5);
		} else if (shop.star - i > 0) {
			ctx.drawImage('../../../static/images/sn_half.png', 10 + 12 * i, y + 5, 10, 9.5);
		} else {
			ctx.drawImage('../../../static/images/sn_empty.png', 10 + 12 * i, y + 5, 10, 9.5);
		}
	}

	ctx.setFontSize(12);
	ctx.fillStyle = '#666666';
	ctx.fillText(shop.star, 70, y + 15); 
	
	// 价格
	let price = _this.goods.product_price
	if (_this.goodsInfo.sell_type == 2) {
		price = _this.goodsInfo.unit_price + '/' + common.changeTxt('斤')
	}
	ctx.setFontSize(14);
	ctx.fillStyle = '#eeae38';
	ctx.fillText(currencySymbol, 10, logo.height + 150);
	ctx.setFontSize(24);
	ctx.fillText(price, 25, logo.height + 150);
	
	console.log('price_width', price_width);
	if (_this.goods.o_price > _this.goods.product_price) {
		ctx.setFontSize(14);
		ctx.fillStyle = '#666666';
		
		var old_price = currencySymbol + _this.goods.o_price
		ctx.fillText(old_price, price_width + 20, logo.height + 150);
		
		const old_price_metrics = ctx.measureText(old_price)
		console.log('商品原价宽度',old_price_metrics)
		ctx.moveTo(price_width + 20, logo.height + 145)
		ctx.lineTo(price_width + 22 + old_price_metrics.width , logo.height + 145)
		ctx.stroke()
	}
	
	// 二维码
	console.log('goods.wxapp_qrcode', goods.wxapp_qrcode);
	wx.getImageInfo({
		src: goods.wxapp_qrcode,
		success: qcode => {
			ctx.drawImage(qcode.path, width - 103, logo.height + 50, 80, 80);
			ctx.setFontSize(12);
			ctx.fillStyle = '#666666';
			ctx.setTextAlign('right');
			ctx.fillText(common.changeTxt('长按小程序码去购买'), width - 10, logo.height + 150);
			ctx.draw();
			setTimeout(() => {
				_this.posterUrl = true;
			}, 300);
		}
	});
};
const saveImg = () => {
	if (_this.posterUrl === true) {
		wx.canvasToTempFilePath({
			canvasId: 'pubShare',
			fileType: 'jpg',
			success: res => {
				wx.saveImageToPhotosAlbum({
					filePath: res.tempFilePath,

					success(res) {
						common.getTxtKey('保存成功!').then(
							key => {
								showToast(key);
							},
							() => {}
						);
					},

					fail: () => {
						wx.getSetting({
							success: res => {
								if (res.authSetting['scope.writePhotosAlbum'] == false) {
									_this.canSave = false;
								}
							}
						});
					}
				});
			}
		});
	}
};
// class节点
const getClassNode = className => {
	wx.createSelectorQuery()
		.selectAll(className)
		.boundingClientRect(function(rects) {
			console.log('777777777777777', rects);
			var width = 0;
			rects.forEach(function(rect) {
				width += rect.width;
			});
			console.log('777777777777777', width);
			price_width = width;
			
			drowPoster();	//由于此方法只用于海报计算，所以在获取到了高度之后再触发画海报
		})
		.exec();
};
// toast显示
const showToast = str => {
	wx.showToast({
		title: str,
		icon: 'none',
		duration: 3000
	});
};
</script>
<style lang="stylus" scoped>
.m-describe {
	font-size:14px;
	color:#666;
}	
.m-sale-info-img
	margin-top 40upx
	margin-bottom 20upx
	height 150upx
	background-image url('')
	background-position center
	background-repeat no-repeat
	background-size cover
.m2.goods-info	
	padding-top 0
	padding-bottom 20upx
	border-top 8upx solid #f6f6f6
.m-product-msg
	padding-top 24upx
	border-top 1px solid #d9d9d9
.m-product-title
	font-size 18px
	font-weight bold
.m-product-item-wrap
	display flex
	flex-wrap wrap
.m-product-item
	height 50upx
	line-height 50upx
	padding 0 8upx
	margin-right 20upx
	margin-top 20upx
	border 1px solid #6c6c6c 
	color #6c6c6c
	font-size 12px
    	
.m-price-title 
	display:flex;
	align-items:center;
	height:100upx;
	font-size 14px
	color #9b9b9b
	image
		width 32upx
		height 31upx
		margin-left 10upx
		margin-top 4upx
	
.m-price-img 
	width 670upx

.border-b::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 10px;
	right: 10px;
	height: 1rpx;
	background: #e5e5e5;
	transform: scaleY(0.5);
}

.border-t::after {
	content: '';
	position: absolute;
	top: 0;
	left: 10px;
	height: 1rpx;
	width: 100%;
	background: #e5e5e5;
	transform: scaleY(0.5);
}

.page {
	background: #fff;
	width: 100%;
	height: 100%;
	overflow-x: hidden;
}

.mr0 {
	margin-right: 0 !important;
}

.mr5 {
	margin-right: 5px;
}

.mb5 {
	margin-bottom: 5px;
}

.rel {
	position: relative;
}

.status-bar {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 60px;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 10px;
	box-sizing: border-box;
	font-size: 18px;
	font-weight: 500;
}

.status-bar .title {
	position: absolute;
	text-align: center;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.status-bar .model {
	width: 34px;
}

.status-bar .icon-shouye {
	font-size: 50rpx;
	position: relative;
}

.status-bar .icon-arrow-left {
	position: relative;
}

.status-bar .icon-arrow-left::after,
.status-bar .icon-shouye::after {
	content: '';
	position: absolute;
	top: -10px;
	left: -10px;
	right: -10px;
	bottom: -10px;
}

.status-bar .left-desc {
	position: relative;
	font-size: 16px;
	font-weight: normal;
}

.swiper-box {
	position: relative;
}

.swiper {
	width: 100%;
}

.swiper-box image {
	width: 100%;
	height: 100%;
}

.swiper .wx-swiper-dots.wx-swiper-dots-horizontal {
	margin-bottom: -5px;
}

.swiper .wx-swiper-dot {
	height: 10rpx;
	width: 10rpx;
}

.swiper .wx-swiper-dot-active {
	width: 25rpx;
	display: inline-flex;
	height: 10rpx;
	justify-content: space-between;
}

.swiper .wx-swiper-dot::before {
	content: '';
	flex-grow: 1;
	border-radius: 8rpx;
}

.swiper .wx-swiper-dot-active::before {
	background: #06c1ae;
}

.goods-info {
	padding: 15px;
	position: relative;
}
.goods-info .desc-box{
	display: flex;
	overflow: hidden;
	margin-bottom: 36rpx;
}
.goods-info .desc-box .left{
	flex-grow: 1;
	padding-right: 10px
}
.goods-info .desc-box .share-btn {
	font-size: 12px;
	text-align: center;
}

.goods-info .desc-box .share-btn .iconfont{
	font-size: 14px;
	border: 1px solid #efefef;
	padding: 6px;
	border-radius: 50%;
	margin-bottom: 2px;
	display: inline-block
}

.goods-info .name {
	font-size: 18px;
	color: #333;
	margin-bottom: 2px;
	font-weight: bold;
}

.goods-info .num-box {
	font-size: 12px;
	color: #999;
	margin: 5px 0;
}

.goods-info .num-box .num {
	margin-right: 5px;
}

.price-box {
	display: flex;
	justify-content: space-between;
	font-size: 16px;
}

.price-box .price {
	color: #e23321;
	font-size: 22px;
	margin-right: 5px;
}

.price-box .old-price {
	text-decoration: line-through;
	color: #999;
	font-size: 12px;
	margin-right: 5px;
}

.price-box .discount {
	color: #d45740;
	font-size: 11px;
	margin-right: 5px;
}

.price-box .discount.num {
	border: 1rpx solid #f8e6e2;
	border-radius: 2px;
}

.price-box .stock {
	color: #999;
	font-size: 11px;
}

.price-box count {
	line-height: 30px;
}

.weight-box{
	font-size: 13px;
	color: #333;
}

.weight-box .desc-box{
	margin-top: 8px;
	display: flex;
	align-items: center;
}

.weight-box .desc-box .tag{
	border: 1px solid #efefef;
	margin-right: 5px;
	padding: 2px 10px;
}

.weight-box .desc-box .iconfont{
	margin-left: 5px;
	font-size: 14px;
	color: #999;
	position: relative;
}
.weight-box .desc-box .iconfont::after{
	content: '';
	position: absolute;
	top: -8px;
	left: -40px;
	right: -20px;
	bottom: -8px;
}

.remarks .name {
	font-size: 16px;
	margin-bottom: 15px;
}

.remarks .select-flavor {
	display: flex;
	align-items: center;
	font-size: 14px;
	margin-bottom: 10px;
}

.remarks .select-flavor:last-child {
	margin-bottom: 0;
}

.remarks .select-flavor .title {
	color: #666;
	margin: 0 10px 10px 0;
	white-space: nowrap;
}

.remarks .select-flavor .flavor-box {
	display: flex;
	flex-wrap: wrap;
}

.remarks .select-flavor .item {
	margin: 0 10px 10px 0;
	padding: 6px 20px;
	background: #f5f5f5;
	border-radius: 3px;
	color: #333;
}

.remarks .select-flavor .item.active {
	color: #06c1ae;
	background: #e5e5e5;
}

.remarks .goods-desc {
	font-size: 12px;
	color: #666;
	margin-bottom: 10px;
}

.remarks .goods-img image {
	width: 100%;
	height: 100px;
}

.icon-shouye1 {
	position: fixed;
	bottom: 60px;
	right: 10px;
	color: rgba(0, 0, 0, 0.5);
	font-size: 36px;
}

/* 商品描述 */
.desc-text {
	font-size: 14px;
	color: #666;
	line-height: 2;
}

/* 分享按钮 */
.mask_bg {
	position: fixed;
	z-index: 9999;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #000;
	opacity: 0.5;
}

.shareBtnsContent {
	position: fixed;
	z-index: 10000;
	bottom: 0;
	left: 0;
	width: 100%;
	background: #fff;
	transition: all 0.3s ease;
	-webkit-transition: all 0.3s ease;
	transform: translate(0, 150%);
	-webkit-transform: translate(0, 150%);
}

.shareBtnsContent .pub_list {
	padding: 15px 0 20px;
	display: flex;
	justify-content: space-around;
	position: relative;
}

.shareBtnsContent.active {
	transform: translate(0, 0);
	-webkit-transform: translate(0, 0);
}

.shareBtnsContent .pub_list .icon-weixin2 {
	color: #00cd0c;
	font-size: 42px;
}

.shareBtnsContent .pub_list .icon-pengyouquan {
	color: #00cd0c;
	font-size: 42px;
}

.shareBtnsContent .pub_list .txt {
	font-size: 14px;
	color: #333;
}

.shareBtnsContent .icon-cha {
	position: absolute;
	right: 5px;
	top: -30px;
	font-size: 24px;
	color: #fff;
}

/* 取消button的默认样式 */
button::after {
	border: none;
}

.button_share {
	padding-left: 0;
	padding-right: 0;
	background-color: white;
	line-height: 1.4;
}

.canvas-box {
	padding-bottom: 45px;
	box-sizing: border-box;
}

.canvas-box .goods {
	width: 80%;
	box-sizing: border-box;
	position: relative;
	box-shadow: 0 0 10px 5px #efefef;
	margin: 5% auto;
}

.canvas-box .goods .img {
	width: 100%;
	height: 320px;
}

.canvas-box .goods .goods-name {
	font-size: 14px;
	color: #333;
	margin: 5px 0;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.canvas-box .goods .store-name {
	font-size: 12px;
	color: #666;
	margin-bottom: -6px;
	width: calc(100% - 100px);
}

.canvas-box .goods .star {
	display: flex;
	align-items: flex-end;
}

.canvas-box .goods .star text {
	font-size: 12px;
	color: #666;
	padding: 3px 0;
}

.canvas-box .goods .price-desc {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-size: 12px;
	color: #666;
	margin-top: 30px;
}

.canvas-box .goods .price-desc .price {
	color: #ffc900;
}

.canvas-box .goods .price-desc .price.num {
	font-size: 24px;
}

.canvas-box .goods .price-desc .o-price {
	text-decoration: line-through;
	margin-left: 5px;
}

.canvas-box .goods .qcode {
	position: absolute;
	right: 28px;
	bottom: 32px;
	width: 60px;
	height: 60px;
}

.canvas-box .icon-cha {
	position: fixed;
	top: 2px;
	right: 2px;
	font-size: 30px;
	color: #ccc;
}

.cancel-icon {
	position: fixed;
	top: 5px;
	right: 10px;
	font-size: 24px;
	color: #999;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.7);
	width: 50px;
	height: 50px;
}

.canvas-box .btn-box {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 10px 0;
}

.save-img {
	width: 70%;
	background: #33d25f;
	color: #fff;
	border-radius: 20px;
	font-size: 14px;
}

.save-desc {
	font-size: 12px;
	color: #666;
	text-align: center;
	margin-top: 5px;
}

.weight-desc {
	background: #fff;
	padding: 10px;
}

.weight-desc .title {
	font-size: 16px;
	text-align: center;
	color: #333;
	margin-top: 5px;
}

.weight-desc .desc {
	font-size: 13px;
	color: #999;
	line-height: 1.5;
	margin: 20px 0;
}

.weight-desc .btn {
	background: #e23321;
	color: #fff;
}

/* 附属菜 */
.linked-goods .type-name {
	background: #f4f4f4;
	padding: 10px;
	font-size: 16px;
	font-weight: bold;
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
}

.linked-goods .type-name .limit {
	color: #e23321;
	font-size: 12px;
	font-weight: normal;
}

.linked-goods .item {
	padding: 10px;
	position: relative;
	font-size: 14px;
	color: #333;
}

.linked-goods .item-info {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.linked-goods .item:last-child::after {
	height: 0;
}

.linked-goods .item-info .price {
	color: #999;
	display: inline-block;
}

.linked-goods .item-desc {
	color: #999;
	font-size: 12px;
	margin-right: 80px;
}

.add-to-cart {
	position: fixed;
	bottom: 80px;
	width: 70%;
	background: #06c1ae;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 15%;
	padding: 5px 15px 5px 5px;
	color: #fff;
	font-size: 14px;
	border-radius: 20px;
	box-sizing: border-box;
}

.add-to-cart .count-mask {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
}

.add-to-cart .iconfont {
	margin-right: 5px;
	vertical-align: middle;
}

.count-box {
	display: flex;
	line-height: 28px;
}

.count-box .iconfont {
	color: #06c1ae;
	font-size: 26px;
	position: relative;
}

.count-box .iconfont.active {
	color: #999;
}

.count-box .iconfont::after {
	content: '';
	position: absolute;
	top: -10px;
	left: -10px;
	right: -10px;
	bottom: -10px;
}

.count-box .num {
	padding: 0 3px;
	color: #333;
	min-width: 20px;
	text-align: center;
}

.mask {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 10000;
}

.spec-content-wrapper {
	position: fixed;
	left: 0;
	bottom: 0;
	right: 0;
	top: 0;
	transform: translateY(100%);
	transition: all 0.3s;
	z-index: 10001;
}

.spec-content {
	position: absolute;
	left: 0;
	bottom: 0;
	right: 0;
	background: #fff;
	padding-top: 93px;
	box-sizing: border-box;
}

.spec-content-wrapper.active {
	transform: translateY(0);
}

.spec-content .header {
	display: flex;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
}

.spec-content .header .icon-cha {
	position: absolute;
	right: 0;
	top: 0;
	padding: 10px;
	font-size: 24px;
	color: #999;
}

.spec-content .header .goods-info {
	width: 100%;
}

.spec-content .header .goods-info .name {
	width: calc(100% - 20px);
	margin-bottom: 10px;
}

.spec-content .header .goods-info .select-btn {
	background: #06c1ae;
	color: #fff;
	line-height: 28px;
	font-size: 14px;
	border-radius: 15px;
	padding: 0 15px;
}

.spec-content .header .goods-info .select-btn.active {
	background: #999;
}

.spec-content .header .goods-info .select-btn .iconfont {
	font-size: 14px;
	margin-right: 5px;
	font-weight: bold;
}

.spec-content .spec-box {
	overflow-y: auto;
	overflow-x: hidden;
}

.spec-content.type-list {
	padding-top: 0;
	padding-bottom: 50px;
}

.spec-content.type-list .line-wrapper {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px;
	background: #f4f4f4;
	font-size: 12px;
	color: #333;
}

.spec-content.type-list .select-goods {
	background: #fff;
	overflow-y: scroll;
	overflow-x: hidden;
}

.spec-content.type-list .goods-items {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: #fff;
	position: relative;
	padding: 10px;
	font-size: 16px;
	height: 30px;
	color: #333;
}

.spec-content.type-list .goods-items:first-child::after {
	height: 0;
}

.spec-content.type-list .goods-items > view {
	flex: 1;
}

.spec-content.type-list .goods-items .name {
	flex: 3;
	font-size: 14px;
}

.spec-content.type-list .goods-items .count-box {
	margin-top: 2px;
}

.spec-content.type-list .cart {
	height: 50px;
	background-color: #32312e;
	color: #fff;
	font-size: 16px;
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-left: 10px;
}

.spec-content.type-list .cart .btn {
	background: #06c1ae;
	padding: 0 15px;
	height: 50px;
	line-height: 50px;
}

.pack-meal{
	background: #F4F4F4;
	padding: 20rpx 0;
}
.pack-meal-wrapper {
	background: #fff;
	padding: 20rpx;
}

.pack-meal-wrapper .list .item{
	background: #FAFAFA;
	margin-bottom: 20rpx;
	border-radius: 10rpx;
}
.pack-meal-wrapper .list .item:last-child{
	margin-bottom: 0;
}

.pack-meal-wrapper .list .item .title{
	padding: 20rpx;
	font-size: 12px;
	color: #333;
}
.pack-meal-wrapper .list .item .title .dot{
	margin: 0 3px;
}

.pack-meal-wrapper .list .item .goods-list{
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 12px;
	color: #333;
	text-align: center;
	padding: 0 20rpx 10px;
}

.pack-meal-wrapper .list .item .goods-list .goods{
	display: flex;
	align-items: center;
}

.pack-meal-wrapper .list .item .goods-list .goods .icon{
	color: #ccc;
	font-size: 20px;
	padding: 0 20rpx 27px;
}
.pack-meal-wrapper .list .item .goods-list .goods .icon:last-child{
	display: none;
}

.pack-meal-wrapper .list .item .goods-list .goods .goods-item .img-box{
	width: 85px;
	height: 85px;
	margin-bottom: 10px;
	border-radius: 5px;
	overflow: hidden;
}
.pack-meal-wrapper .list .item .goods-list .goods .goods-item .img-box .img{
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.pack-meal-wrapper .list .item .goods-list .goods .goods-item .goods-name{
	display: inline-block;
	width: 85px;
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
}
.pack-meal-wrapper .list .item .price{
	padding-bottom: 27px;
	display: none;
}
.pack-meal-wrapper .list .item .goods-list .price{
	display: block;
}
.pack-meal-wrapper .list .item .price .red {
	color: #E34D43;
}
.pack-meal-wrapper .list .item .price .btn{
	display: inline-block;
	background: #21C0AE;
	padding: 4px 15px;
	color: #fff;
	border-radius: 15px;
	margin-top: 10px;
}
.pack-meal-wrapper .list .item .price .ml5{
	margin-left: 5px;
}
.pack-meal-wrapper .list .item .price  .now-price{
	font-size: 16px;
}
.pack-meal-wrapper .list .item.three .goods{
	width: 100%;
	justify-content: space-between;
}
.pack-meal-wrapper .list .item.three .price{
	padding-bottom: 10px;
	padding-right: 10px;
	text-align: right;
	font-size: 12px;
	color: #333;
	display: block;
}
.pack-meal-wrapper .list .item.three .goods-list .price{
	display: none;
}
.pack-meal-wrapper .list .item.three .price .ml10{
	margin-left: 10px;
}
.pack-meal-wrapper .list .item.three .price .txt{
	margin-right: 2px;
}
.pack-meal-wrapper .list .item.three .price .btn{
	margin-top: 0;
}

.pack-meal-wrapper .list .see-more{
	background: #FAFAFA;
	padding: 20rpx 0;
	font-size: 14px;
	color: #333;
	border-radius: 2px;
	display: flex;
	align-items: center;
	justify-content: center;
}
.pack-meal-wrapper .list .see-more .img{
	width: 20px;
	height: 20px;
	border-radius: 2px;
	margin-right: 5px;
}
.pack-meal-wrapper .list .see-more .icon-jiantou{
	color: #999;
	font-size: 18px;
}

.pack-meal-mask{
	max-height: 80%;
	border-radius: 10px 10px 0 0;
	background: #f8f8f8 !important;
	overflow: hidden;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}

.pack-meal-mask .shop-info{
	display: flex;
	align-items: center;
	padding: 10px;
}
.pack-meal-mask .shop-info .img-box{
	width: 40px;
	height: 40px;
	margin-right: 10px;
}
.pack-meal-mask .shop-info .img-box .img{
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.pack-meal-mask .shop-info .shop-name{
	color: #333;
}
.pack-meal-mask .shop-info .score{
	color: #EFA346;
	font-size: 12px;
}
.pack-meal-mask .shop-info .delivery-time{
	font-size: 12px;
	margin-left: 10px;
	color: #333;
}

.pack-meal-mask .shop-info .icon-chahao{
	position: absolute;
	right: 0;
	top: 0;
	font-size: 20px;
	color: #999;
	padding: 5px 5px 10px 10px;
}

.pack-meal-mask .list{
	max-height: calc(100% - 44px);
	overflow-y: auto;
	padding: 0 10px;
}

.pack-meal-mask .list .pack-goods{
	box-shadow: 0 0px 6px #eee;
	margin-bottom: 10px;
	background: #fff;
	padding: 15px;
	border-radius: 5px;
}

.pack-meal-mask .list .pack-goods .goods-list{
	display: flex;
}

.pack-meal-mask .list .pack-goods .goods-list .item{
	flex: 1;
	margin-right: 15px;
	color: #333;
	font-size: 12px;
}

.pack-meal-mask .list .pack-goods .goods-list .item:last-child{
	margin-right: 0;
}
.pack-meal-mask .list .pack-goods .goods-list .item .img-box{
	position: relative;
	margin-bottom: 5px;
	border-radius: 5px;
	overflow: hidden;
}
.pack-meal-mask .list .pack-goods .goods-list .item .img-box:after{
	content: '';
	display: inline-block;
	width: 100%;
	padding-top: 100%;
}
.pack-meal-mask .list .pack-goods .goods-list .item .img-box .img{
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.pack-meal-mask .list .pack-goods .goods-list .item .img-box .sell-count{
	position: absolute;
	top: 0;
	left: 0;
	background: #33312D;
	color: #E3BE70;
	padding: 2px 6px;
	border-radius: 0 0 5px 0;
}
.pack-meal-mask .list .pack-goods .goods-list .item .goods-name{
	text-overflow: -o-ellipsis-lastline;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	word-break: break-all;
}

.pack-meal-mask .list .pack-goods .price{
	text-align: right;
	font-size: 12px;
	margin-top: 5px;
}
.pack-meal-mask .list .pack-goods .price .btn{
	background: #21C0AE;
	color: #fff;
	font-size: 12px;
	padding: 4px 14px;
	border-radius: 14px;
}
.pack-meal-mask .list .pack-goods .price .red{
	color: #E34D43;
}
.pack-meal-mask .list .pack-goods .price .ml10{
	margin-left: 10px;
}
.pack-meal-mask .list .pack-goods .price .now-price{
	font-size: 18px;
}
.pack-meal-mask .list .pack-goods .price .txt{
	color: #666;
	margin-right: 2px;
}
.return-shop {
	position: fixed;
	right: 0;
	bottom: 200px;
	background: rgba(0,0,0,0.5);
	color: #fff;
	font-size: 12px;
	width: 45px;
	height: 40px;
	display: flex;
	align-items: center;
	border-radius: 5px 0 0 5px;
}
</style>
